import fs from 'node:fs';
import download from 'download-git-repo';
import ora from 'ora';
const spinner = ora('下载中...');
//验证路径
export const checkPath = (path) => {
    return fs.existsSync(path);
};

//下载
export const downloadTemp = (branch, project) => {
    spinner.start();
    return new Promise((resolve, reject) => {
        console.log(branch, 'branch');
        download(`direct:https://gitee.com/liweisum/pdv-basic.git#${branch}`, project, { clone: true }, function (err) {
            if (err) {
                reject(err);
                console.log(err);
            }

            resolve();
            spinner.succeed('下载完成');
        });
    });
};
